<!DOCTYPE html><html lang="zh-CN" data-theme="dark"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Uni-app | 北城韩雨</title><meta name="keywords" content="微信"><meta name="author" content="北城韩雨"><meta name="copyright" content="北城韩雨"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#0d0d0d"><meta name="description" content="微信">
<meta property="og:type" content="article">
<meta property="og:title" content="Uni-app">
<meta property="og:url" content="http://example.com/2020/04/21/uni-app/index.html">
<meta property="og:site_name" content="北城韩雨">
<meta property="og:description" content="微信">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic.vjshi.com%2F2017-07-20%2F4f06f9aa2ebcea6691a78537052e8e9f%2F00001.jpg%3Fx-oss-process%3Dstyle%2Fwatermark&refer=http%3A%2F%2Fpic.vjshi.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1629530599&t=32fb97bad7007bdc6c712ccadacd5721">
<meta property="article:published_time" content="2020-04-20T16:00:00.000Z">
<meta property="article:modified_time" content="2019-06-02T16:00:00.000Z">
<meta property="article:author" content="北城韩雨">
<meta property="article:tag" content="小程序">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic.vjshi.com%2F2017-07-20%2F4f06f9aa2ebcea6691a78537052e8e9f%2F00001.jpg%3Fx-oss-process%3Dstyle%2Fwatermark&refer=http%3A%2F%2Fpic.vjshi.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1629530599&t=32fb97bad7007bdc6c712ccadacd5721"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="http://example.com/2020/04/21/uni-app/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: undefined,
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'mediumZoom',
  Snackbar: undefined,
  source: {
    jQuery: 'https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js',
      css: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isanchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'Uni-app',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2019-06-03 00:00:00'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
    const detectApple = () => {
      if (GLOBAL_CONFIG_SITE.isHome && /iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><link rel="stylesheet" href="/css/custom.css"  media="defer" onload="this.media='all'"><link rel="stylesheet" href="/css/coin.css"  media="defer" onload="this.media='all'"><link rel="stylesheet" href="/css/liuxing.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/l-lin/font-awesome-animation/dist/font-awesome-animation.min.css"  media="defer" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper/swiper-bundle.min.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/zhheo/JS-Heo@main/bb/showbb_in_index.css"><!-- hexo injector head_end start --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css" media="print" onload="this.media='screen'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/l-lin/font-awesome-animation/dist/font-awesome-animation.min.css" media="defer" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/hexo-butterfly-tag-plugins-plus/lib/tag_plugins.min.css" media="defer" onload="this.media='all'"><!-- hexo injector head_end end --><meta name="generator" content="Hexo 5.3.0"></head><body><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="/img/my.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/archives/"><div class="headline">文章</div><div class="length-num">65</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/tags/"><div class="headline">标签</div><div class="length-num">23</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/categories/"><div class="headline">分类</div><div class="length-num">21</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/"><i class="fa-fw fas fa-home faa-tada"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/shuoshuo/"><i class="fa-fw fas fa-archive faa-tada"></i><span> 叨逼叨</span></a></div><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/tags/"><i class="fa-fw fas fa-tags faa-tada"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/categories/"><i class="fa-fw fas fa-folder-open faa-tada"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/link/"><i class="fa-fw fas fa-link faa-tada"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/comments/"><svg class="icon faa-tada" aria-hidden="true"><use xlink:href="#icon-message"></use></svg><span> 留言板</span></a></div><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/about/"><i class="fa-fw fas fa-heart faa-tada"></i><span> 个人简介</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic.vjshi.com%2F2017-07-20%2F4f06f9aa2ebcea6691a78537052e8e9f%2F00001.jpg%3Fx-oss-process%3Dstyle%2Fwatermark&amp;refer=http%3A%2F%2Fpic.vjshi.com&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=jpeg?sec=1629530599&amp;t=32fb97bad7007bdc6c712ccadacd5721')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">北城韩雨</a></span><div id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/"><i class="fa-fw fas fa-home faa-tada"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/shuoshuo/"><i class="fa-fw fas fa-archive faa-tada"></i><span> 叨逼叨</span></a></div><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/tags/"><i class="fa-fw fas fa-tags faa-tada"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/categories/"><i class="fa-fw fas fa-folder-open faa-tada"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/link/"><i class="fa-fw fas fa-link faa-tada"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/comments/"><svg class="icon faa-tada" aria-hidden="true"><use xlink:href="#icon-message"></use></svg><span> 留言板</span></a></div><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/about/"><i class="fa-fw fas fa-heart faa-tada"></i><span> 个人简介</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">Uni-app</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2020-04-20T16:00:00.000Z" title="发表于 2020-04-21 00:00:00">2020-04-21</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2019-06-02T16:00:00.000Z" title="更新于 2019-06-03 00:00:00">2019-06-03</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E5%BE%AE%E4%BF%A1/">微信</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">3k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>11分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="Uni-app"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h2 id="uni-app介绍"><a href="#uni-app介绍" class="headerlink" title="uni-app介绍"></a>uni-app介绍</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">uni-app是一个使用vue.js开发所有前端的应用的框架，开发者编写一套代码 可发布到IOS Android H5 以及各种小程序</span><br><span class="line">即使不跨段 uni-app同时也是更好的小程序开发框架</span><br></pre></td></tr></table></figure>
<h2 id="环境搭建"><a href="#环境搭建" class="headerlink" title="环境搭建"></a>环境搭建</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>需要安装HbuilderX  APP开发板</span><br><span class="line"><span class="number">2.</span>安装微信开发者工具</span><br><span class="line"><span class="number">3.</span>创建项目 新建 - uni-app项目</span><br><span class="line"><span class="number">4.</span>运行 直接点运行 就可以看到运行到浏览器 模拟器之类的</span><br><span class="line"><span class="number">5.</span>运行 到微信开发者工具 首先第一次运行需要在Hbuilder配置微信开发者工具所在的位置 第二 需要在微信开发者工具里的安全设置端口</span><br></pre></td></tr></table></figure>
<h2 id="文件目录详解"><a href="#文件目录详解" class="headerlink" title="文件目录详解"></a>文件目录详解</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>pages.json  主要用来对uni-app进行全局设置，决定页面文件的路径、窗口样式、原生的导航栏、底部的原生tabbar等</span><br><span class="line"><span class="number">2.</span>manifest.json 主要是应用的配置文件、用于指定应用的名称、图标、权限等</span><br><span class="line"><span class="number">3.</span>app.vue 是我们的根组件，所有页面都是在app.vue下进行切换的，是页面的入口文件，可调用应用的生命周期函数</span><br><span class="line"><span class="number">4.</span>main.js 是我们项目文件的入口文件 主要作用是初始化vue实例并使用需要的插件</span><br><span class="line">uni.scss 用途是为了方便整体控制应用的风格，比如按钮颜色、边框风格，uni.scss 文件里预设了一批scss变量预值</span><br><span class="line">unpackage 就是打包目录 在这里有各个平台的打包文件</span><br><span class="line">page 所有页面存放的目录</span><br><span class="line"><span class="keyword">static</span> 静态资源目录 列入图片</span><br><span class="line">components 组件存放目录</span><br></pre></td></tr></table></figure>
<h2 id="page-json文件详解"><a href="#page-json文件详解" class="headerlink" title="page.json文件详解"></a>page.json文件详解</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>这里分为全局的配置和页面级的配置</span><br><span class="line"><span class="number">2.</span>比如头部 我们全局都会有头部和标题 但是每个页面也会有头部和标题 这样就可以单独配置一下全局的和页面的</span><br><span class="line"><span class="number">3.</span>如果页面的头部和标题没有配置 那么全局会替代掉</span><br><span class="line"><span class="number">4.</span>其他配置项页是如此</span><br><span class="line"><span class="number">5.</span>具体的一些详细配置查看API文档 比如下拉刷新之类的</span><br></pre></td></tr></table></figure>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//初始结构</span></span><br><span class="line"><span class="number">1.</span>初始结构</span><br><span class="line">&#123;</span><br><span class="line">    <span class="comment">//页面的配置 如每个页面的头部颜色 文字</span></span><br><span class="line">	<span class="string">&quot;pages&quot;</span>: [ <span class="comment">//pages数组中第一项表示应用启动页，参考：https://uniapp.dcloud.io/collocation/pages</span></span><br><span class="line">		&#123;</span><br><span class="line">			<span class="string">&quot;path&quot;</span>: <span class="string">&quot;pages/index/index&quot;</span>,</span><br><span class="line">			<span class="string">&quot;style&quot;</span>: &#123;</span><br><span class="line">				<span class="string">&quot;navigationBarTitleText&quot;</span>: <span class="string">&quot;uni-app&quot;</span></span><br><span class="line">			&#125;</span><br><span class="line">		&#125;</span><br><span class="line">	],</span><br><span class="line">     <span class="comment">//全局的配置</span></span><br><span class="line">	<span class="string">&quot;globalStyle&quot;</span>: &#123;</span><br><span class="line">		<span class="string">&quot;navigationBarTextStyle&quot;</span>: <span class="string">&quot;black&quot;</span>,</span><br><span class="line">		<span class="string">&quot;navigationBarTitleText&quot;</span>: <span class="string">&quot;uni-app&quot;</span>,</span><br><span class="line">		<span class="string">&quot;navigationBarBackgroundColor&quot;</span>: <span class="string">&quot;#7FFF00&quot;</span>,</span><br><span class="line">		<span class="string">&quot;backgroundColor&quot;</span>: <span class="string">&quot;#F8F8F8&quot;</span></span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h2 id="创建新的页面"><a href="#创建新的页面" class="headerlink" title="创建新的页面"></a>创建新的页面</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>在page文件夹里右键新建页面和文件即可</span><br><span class="line"><span class="number">2.</span>新建完毕之后 需要在pages.json文件里 把你的页面路径写入进去</span><br></pre></td></tr></table></figure>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//这里那个是在数组的第一位 就会显示为当前页面</span></span><br><span class="line"><span class="string">&quot;pages&quot;</span>: [ </span><br><span class="line">    &#123;</span><br><span class="line">        <span class="string">&quot;path&quot;</span>: <span class="string">&quot;pages/message/message&quot;</span>,</span><br><span class="line">        <span class="string">&quot;style&quot;</span>: &#123;</span><br><span class="line">            <span class="string">&quot;navigationBarTitleText&quot;</span>: <span class="string">&quot;新建页面&quot;</span></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;,</span><br><span class="line">    &#123;</span><br><span class="line">        <span class="string">&quot;path&quot;</span>: <span class="string">&quot;pages/index/index&quot;</span>,</span><br><span class="line">        <span class="string">&quot;style&quot;</span>: &#123;</span><br><span class="line">            <span class="string">&quot;navigationBarTitleText&quot;</span>: <span class="string">&quot;uni-app&quot;</span></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">],</span><br></pre></td></tr></table></figure>
<h2 id="Tabbar的配置"><a href="#Tabbar的配置" class="headerlink" title="Tabbar的配置"></a>Tabbar的配置</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>首先需要写在page.json文件里</span><br><span class="line"><span class="number">2.</span>他和page 和 globalStyle 是同级别的配置</span><br><span class="line"><span class="number">3.</span>具体的tabbar要求和规范见详细文档</span><br></pre></td></tr></table></figure>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//最少要有两个</span></span><br><span class="line"><span class="string">&quot;globalStyle&quot;</span>: &#123;</span><br><span class="line">		<span class="string">&quot;navigationBarTextStyle&quot;</span>: <span class="string">&quot;black&quot;</span>,</span><br><span class="line">		<span class="string">&quot;navigationBarTitleText&quot;</span>: <span class="string">&quot;uni-app&quot;</span>,</span><br><span class="line">		<span class="string">&quot;navigationBarBackgroundColor&quot;</span>: <span class="string">&quot;#7FFF00&quot;</span>,</span><br><span class="line">		<span class="string">&quot;backgroundColor&quot;</span>: <span class="string">&quot;#F8F8F8&quot;</span></span><br><span class="line">	&#125;,</span><br><span class="line">     <span class="comment">//和global为同级</span></span><br><span class="line">	<span class="string">&quot;tabBar&quot;</span>:&#123;</span><br><span class="line">		<span class="string">&quot;list&quot;</span>:[</span><br><span class="line">			&#123;</span><br><span class="line">				<span class="string">&quot;test&quot;</span>:首页<span class="string">&quot;&quot;</span>,</span><br><span class="line">				<span class="string">&quot;pagePath&quot;</span>:<span class="string">&quot;pages/index/index&quot;</span>, <span class="comment">//点击的时候显示的页面</span></span><br><span class="line">				<span class="string">&quot;iconPath&quot;</span>:<span class="string">&quot;static/tabs/1.png&quot;</span>, <span class="comment">//默认图标</span></span><br><span class="line">				<span class="string">&quot;selectedIconPath&quot;</span>:<span class="string">&quot;static/tabs/active.png&quot;</span> <span class="comment">//选中图表</span></span><br><span class="line">			&#125;</span><br><span class="line">		]</span><br><span class="line">	&#125;</span><br></pre></td></tr></table></figure>
<h2 id="condition启动模式配置"><a href="#condition启动模式配置" class="headerlink" title="condition启动模式配置"></a>condition启动模式配置</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>我们在浏览器的地址栏中可以直接输入文件目录来访问文件</span><br><span class="line"><span class="number">2.</span>在小程序中可以把page提到数组的第一个位置 但是比较麻烦</span><br><span class="line"><span class="number">3.</span>就可以通过condition来配置当前页面显示</span><br><span class="line"><span class="number">4.</span>比如我们在从商品列表跳转到商品详情页面的时候 需要传递一个ID </span><br></pre></td></tr></table></figure>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//和global-style page tabbar 是同级</span></span><br><span class="line"><span class="string">&quot;condition&quot;</span>:&#123;</span><br><span class="line">		<span class="string">&quot;current&quot;</span>: <span class="number">0</span>,</span><br><span class="line">		<span class="string">&quot;list&quot;</span>:[</span><br><span class="line">			&#123;</span><br><span class="line">				<span class="string">&quot;name&quot;</span>:<span class="string">&quot;详情页&quot;</span>,</span><br><span class="line">                <span class="comment">//调换到哪个页面</span></span><br><span class="line">				<span class="string">&quot;path&quot;</span>:<span class="string">&quot;pages/message/message&quot;</span>,</span><br><span class="line">                <span class="comment">//跳转的时候带的参数</span></span><br><span class="line">				<span class="string">&quot;query&quot;</span>:<span class="string">&quot;id=80&quot;</span></span><br><span class="line">			&#125;</span><br><span class="line">		]</span><br><span class="line">	&#125;</span><br><span class="line"><span class="comment">//以上配置完毕之后 会在微信开发这工具普通编译的下拉框里 就会出现你name的那个页面 点击页面参数 就可以看到传递过来的参数</span></span><br></pre></td></tr></table></figure>
<h2 id="uni-app组件的使用"><a href="#uni-app组件的使用" class="headerlink" title="uni-app组件的使用"></a>uni-app组件的使用</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>view标签 相当于div</span><br><span class="line"><span class="number">2.</span>text标签 相当于span 里面会有一些属性 </span><br><span class="line"><span class="number">3.</span>其他标签组件 查看具体uni-app文档</span><br></pre></td></tr></table></figure>
<h2 id="uni-app样式"><a href="#uni-app样式" class="headerlink" title="uni-app样式"></a>uni-app样式</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>首先我们的uni-app采用的是rpx单位 即所有的屏幕宽度都是<span class="number">750</span> 所以我们在做小程序的时候 让设计高变成<span class="number">750</span>即可 然后我们就按照设计稿的单位去布局即可</span><br><span class="line"><span class="number">2.</span>导入外部的样式的时候 我们就采用@<span class="keyword">import</span> url(<span class="string">&#x27;要导入文件的路径&#x27;</span>) 支持常用选择器 但是不能使用* page 相当于baody节点</span><br><span class="line"><span class="number">3.</span>当使用字体图标的时候 小于40kb会自动转换为base64 如果大于40kb 需要自己转换 否则不生效</span><br><span class="line"><span class="number">4.</span>app.vue文件里写的样式 是全局的样式 生效于所有页面</span><br></pre></td></tr></table></figure>
<h2 id="uni-app中使用预编译处理器sass或者less"><a href="#uni-app中使用预编译处理器sass或者less" class="headerlink" title="uni-app中使用预编译处理器sass或者less"></a>uni-app中使用预编译处理器sass或者less</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>首先需要在页面上的style的标签上 lang=<span class="string">&quot;scss&quot;</span></span><br><span class="line"><span class="number">2.</span>点击工具-&gt; 插件安装 安装scss编译</span><br></pre></td></tr></table></figure>
<h2 id="uni-app生命周期"><a href="#uni-app生命周期" class="headerlink" title="uni-app生命周期"></a>uni-app生命周期</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>uni-app的生命周期主要分为俩部分</span><br><span class="line"><span class="number">2.</span>一个是应用的生命周期 比如你的应用开启关闭切换到后台的时候</span><br><span class="line"><span class="number">3.</span>是页面的生命周期</span><br></pre></td></tr></table></figure>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//应用的生命周期 一般定义在app.vue文件里</span></span><br><span class="line">onLuanch 当uni-app初始化完成的时候出发(全局只触发一次)</span><br><span class="line">onShow 当uni-app 启动 或从后台进入前台显示</span><br><span class="line">onHide 当uni-app 从前台进入后台</span><br><span class="line">onError 当uni-app 报错时出发</span><br></pre></td></tr></table></figure>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//页面生命周期</span></span><br><span class="line">onLoad 监听页面加载 其参数为上个页面传递的数据 </span><br><span class="line">onShow 监听页面显示 页面每次出现在屏幕上 包括从夏季页面点返回露出当前页面</span><br><span class="line">onReady 监听页面初次渲染完成</span><br><span class="line">onHide 监听页面隐藏</span><br><span class="line">onUnload 监听页面卸载</span><br></pre></td></tr></table></figure>
<h2 id="页面的下拉刷新第一种方式"><a href="#页面的下拉刷新第一种方式" class="headerlink" title="页面的下拉刷新第一种方式"></a>页面的下拉刷新第一种方式</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>开启页面的下拉刷新有两种方式 </span><br><span class="line"><span class="number">2.</span>在page.json的文件里 找到配置页的当前的路径配置 然后在style选项中开启enablePullDownRefresh</span><br><span class="line"><span class="number">3.</span>然后可以在页面的文件里onPullDownRefresh方法中监听到这个下拉刷新</span><br><span class="line"><span class="number">4.</span>停止下来刷新可以调用uni.stopPullDownRefresh()</span><br></pre></td></tr></table></figure>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//page.json文件里</span></span><br><span class="line">&#123;</span><br><span class="line">	<span class="string">&quot;pages&quot;</span>: [ <span class="comment">//pages数组中第一项表示应用启动页，参考：https://uniapp.dcloud.io/collocation/pages</span></span><br><span class="line">		&#123;</span><br><span class="line">			<span class="string">&quot;path&quot;</span>: <span class="string">&quot;pages/message/message&quot;</span>,</span><br><span class="line">			<span class="string">&quot;style&quot;</span>: &#123;</span><br><span class="line">				<span class="string">&quot;navigationBarTitleText&quot;</span>: <span class="string">&quot;新建页面&quot;</span>,</span><br><span class="line">                <span class="comment">//这里就是为当前的页面开启了下拉刷新</span></span><br><span class="line">				<span class="string">&quot;enablePullDownRefresh&quot;</span>:<span class="literal">true</span></span><br><span class="line">				</span><br><span class="line">			&#125;</span><br><span class="line">		&#125;,</span><br><span class="line">		&#123;</span><br><span class="line">			<span class="string">&quot;path&quot;</span>: <span class="string">&quot;pages/index/index&quot;</span>,</span><br><span class="line">			<span class="string">&quot;style&quot;</span>: &#123;</span><br><span class="line">				<span class="string">&quot;navigationBarTitleText&quot;</span>: <span class="string">&quot;uni-app&quot;</span></span><br><span class="line">			&#125;</span><br><span class="line">		&#125;</span><br><span class="line">	],</span><br><span class="line">&#125;       </span><br></pre></td></tr></table></figure>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//下拉刷新</span></span><br><span class="line">&lt;template&gt;</span><br><span class="line">	&lt;view&gt;</span><br><span class="line">		我是新建的页面</span><br><span class="line">		&lt;view v-<span class="keyword">for</span>=<span class="string">&quot;item in list&quot;</span> :key=<span class="string">&quot;item&quot;</span>&gt;</span><br><span class="line">			&#123;&#123;item&#125;&#125;</span><br><span class="line">		&lt;/view&gt;</span><br><span class="line">	&lt;/view&gt;</span><br><span class="line">&lt;/template&gt;</span><br><span class="line"></span><br><span class="line">&lt;script&gt;</span><br><span class="line">	<span class="keyword">export</span> <span class="keyword">default</span> &#123;</span><br><span class="line">		<span class="function"><span class="title">data</span>(<span class="params"></span>)</span> &#123;</span><br><span class="line">			<span class="keyword">return</span> &#123;</span><br><span class="line">				list:[<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>,<span class="number">4</span>,<span class="number">5</span>]</span><br><span class="line">			&#125;</span><br><span class="line">		&#125;,</span><br><span class="line">		methods: &#123;</span><br><span class="line">			</span><br><span class="line">		&#125;,</span><br><span class="line">         <span class="comment">//监听到页面的下拉刷新事件</span></span><br><span class="line">		<span class="function"><span class="title">onPullDownRefresh</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">			<span class="built_in">this</span>.list.push(<span class="number">6</span>)</span><br><span class="line">            <span class="comment">//停止下拉刷新事件</span></span><br><span class="line">			uni.stopPullDownRefresh()</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line">&lt;/script&gt;</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<h2 id="页面下拉刷新第二种方式"><a href="#页面下拉刷新第二种方式" class="headerlink" title="页面下拉刷新第二种方式"></a>页面下拉刷新第二种方式</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>调用uni.startPullDownRefresh()</span><br><span class="line"><span class="number">2.</span>停用uni.stopPullDownRefresh()</span><br></pre></td></tr></table></figure>
<h2 id="上拉加载"><a href="#上拉加载" class="headerlink" title="上拉加载"></a>上拉加载</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>onReachBottom() 当页面滚动到底部的时候就会加载 </span><br></pre></td></tr></table></figure>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//代码</span></span><br><span class="line">&lt;template&gt;</span><br><span class="line">	&lt;view&gt;</span><br><span class="line">		我是新建的页面</span><br><span class="line">		&lt;view <span class="class"><span class="keyword">class</span></span>=<span class="string">&quot;box&quot;</span> v-<span class="keyword">for</span>=<span class="string">&quot;item in list&quot;</span> :key=<span class="string">&quot;item&quot;</span>&gt;</span><br><span class="line">			&#123;&#123;item&#125;&#125;</span><br><span class="line">		&lt;/view&gt;</span><br><span class="line">	&lt;/view&gt;</span><br><span class="line">&lt;/template&gt;</span><br><span class="line"></span><br><span class="line">&lt;script&gt;</span><br><span class="line">	<span class="keyword">export</span> <span class="keyword">default</span> &#123;</span><br><span class="line">		<span class="function"><span class="title">data</span>(<span class="params"></span>)</span> &#123;</span><br><span class="line">			<span class="keyword">return</span> &#123;</span><br><span class="line">				list:[<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>,<span class="number">4</span>,<span class="number">5</span>,<span class="number">6</span>,<span class="number">7</span>,<span class="number">8</span>,<span class="number">9</span>,<span class="number">10</span>,<span class="number">11</span>,<span class="number">12</span>,<span class="number">13</span>,<span class="number">14</span>]</span><br><span class="line">			&#125;</span><br><span class="line">		&#125;,</span><br><span class="line">         <span class="comment">//页面触底事件</span></span><br><span class="line">		<span class="function"><span class="title">onReachBottom</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">			<span class="built_in">console</span>.log(<span class="string">&#x27;我到底部了&#x27;</span>)</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line">&lt;/script&gt;</span><br><span class="line"></span><br><span class="line">&lt;style&gt;</span><br><span class="line">.box&#123;</span><br><span class="line">	margin-top: 30px;</span><br><span class="line">&#125;</span><br><span class="line">&lt;/style&gt;</span><br></pre></td></tr></table></figure>
<h2 id="网络请求"><a href="#网络请求" class="headerlink" title="网络请求"></a>网络请求</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="title">getData</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">    uni.request(&#123;</span><br><span class="line">        url:<span class="string">&#x27; http://127.0.0.1:7001/&#x27;</span>,</span><br><span class="line">        <span class="function"><span class="title">success</span>(<span class="params">res</span>)</span>&#123;</span><br><span class="line">            <span class="built_in">console</span>.log(res)</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;)</span><br><span class="line">&#125;	</span><br></pre></td></tr></table></figure>
<h2 id="数据缓存"><a href="#数据缓存" class="headerlink" title="数据缓存"></a>数据缓存</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>分为同步和异步</span><br><span class="line"><span class="number">2.</span>存和取都是一样的</span><br><span class="line"><span class="number">3.</span>其他跟H5的本地存储差不多</span><br></pre></td></tr></table></figure>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//存的基本用法</span></span><br><span class="line">uni.setStorage(&#123;</span><br><span class="line">    key:<span class="string">&#x27;&#x27;</span>,</span><br><span class="line">    data:<span class="string">&#x27;要存的数据&#x27;</span>,</span><br><span class="line">    success:<span class="function">() =&gt;</span> &#123;</span><br><span class="line">        <span class="comment">//保存成功的回调函数</span></span><br><span class="line">    &#125;,</span><br><span class="line">    <span class="function"><span class="title">fail</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">        <span class="comment">//调用失败的回调函数</span></span><br><span class="line">    &#125;</span><br><span class="line">&#125;)</span><br></pre></td></tr></table></figure>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//取的基本用法</span></span><br><span class="line">uni.getStorage(&#123;</span><br><span class="line">    data:<span class="string">&#x27;id&#x27;</span>,</span><br><span class="line">    <span class="function"><span class="title">success</span>(<span class="params">res</span>)</span>&#123;</span><br><span class="line">        <span class="built_in">console</span>.log(res,<span class="string">&#x27;我是取的数据&#x27;</span>)</span><br><span class="line">    &#125;</span><br><span class="line">&#125;)</span><br></pre></td></tr></table></figure>
<h2 id="图片上传和预览"><a href="#图片上传和预览" class="headerlink" title="图片上传和预览"></a>图片上传和预览</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>uni.chooseImage(&#123;</span><br><span class="line">    count:<span class="string">&#x27;几张图片&#x27;</span>,</span><br><span class="line">    sizeType:<span class="string">&#x27;原图还是压错图 默认二者都有&#x27;</span>,</span><br><span class="line">    sourceType:<span class="string">&#x27;从相册选图 还是从相机&#x27;</span>,</span><br><span class="line">    success:<span class="function">() =&gt;</span> &#123;<span class="string">&#x27;成功返回突变的本地文件路径列表&#x27;</span>&#125;,</span><br><span class="line">    fail:<span class="function">() =&gt;</span> &#123;<span class="string">&#x27;失败返回的回调&#x27;</span>&#125;</span><br><span class="line">&#125;)</span><br></pre></td></tr></table></figure>
<h2 id="条件编译跨段兼容"><a href="#条件编译跨段兼容" class="headerlink" title="条件编译跨段兼容"></a>条件编译跨段兼容</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>有的元素我们希望在H5中显示 在小程序中不显示 有的需要在小程序中显示 不想他在APP中显示 这个时候就需要条件编译</span><br><span class="line"><span class="number">2.</span>在元素结构中的语法 就是 具体的端的标识查看文档</span><br><span class="line">&lt;!-- #ifdef 端的标识 --&gt;</span><br><span class="line">你要跨端的元素</span><br><span class="line">&lt;!-- #endif --&gt;</span><br><span class="line"><span class="number">3.</span>在方法中的语法</span><br><span class="line"><span class="comment">// #ifdef MP-WEIXIN</span></span><br><span class="line"><span class="built_in">console</span>.log(<span class="string">&#x27;我希望在微信小程序中打印&#x27;</span>)</span><br><span class="line"><span class="comment">//#endif</span></span><br><span class="line"><span class="number">4.</span>在样式中</span><br><span class="line"><span class="comment">/* #ifdef MP-WEIXIN */</span></span><br><span class="line">.box&#123;</span><br><span class="line">    color:red</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">/* #endif */</span></span><br></pre></td></tr></table></figure>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//实例</span></span><br><span class="line">&lt;!-- #ifdef H5 --&gt;</span><br><span class="line">&lt;view&gt;我要在H5中页面显示&lt;/view&gt;</span><br><span class="line">&lt;!-- #endif --&gt;</span><br><span class="line"><span class="comment">//实力</span></span><br><span class="line">methods&#123;</span><br><span class="line">    <span class="function"><span class="title">getdata</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">        <span class="comment">// #ifdef MP-WEIXIN</span></span><br><span class="line">        <span class="built_in">console</span>.log(<span class="string">&#x27;我希望在微信小程序中打印&#x27;</span>)</span><br><span class="line">        <span class="comment">//#endif</span></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h2 id="导航跳转"><a href="#导航跳转" class="headerlink" title="导航跳转"></a>导航跳转</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>主要分为两种 一种是声明式跳转 一种是编程时跳转</span><br><span class="line"><span class="number">2.</span>声明式跳转 主要就是利用navigator 标签取跳转</span><br><span class="line"><span class="number">3.</span>编程式跳转 主要应用api去跳转 uni.navigateTo(&#123;<span class="attr">url</span>:<span class="string">&#x27;页面路径&#x27;</span>&#125;)</span><br></pre></td></tr></table></figure>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//声明式跳转 </span></span><br><span class="line">&lt;navigator url=<span class="string">&quot;/pages/index/index&quot;</span>&gt;跳转去index页面&lt;/navigator&gt;</span><br><span class="line"><span class="comment">//跳转到tabbar的页面 需要加上 open-type=&quot;switchTab&quot;</span></span><br><span class="line">&lt;navigator url=<span class="string">&quot;/pages/index/index&quot;</span> open-type=<span class="string">&quot;switchTab&quot;</span>&gt;跳转去tabbar页面&lt;/navigator&gt;</span><br><span class="line"><span class="comment">//redirect 属性的跳转 会把上一个页面关闭(销毁)也就式没有回退按钮</span></span><br><span class="line"><span class="comment">//跳转到tabbar的页面 需要加上 open-type=&quot;switchTab&quot;</span></span><br><span class="line">&lt;navigator url=<span class="string">&quot;/pages/index/index&quot;</span> open-type=<span class="string">&quot;redirect&quot;</span>&gt;跳转去tabbar页面&lt;/navigator&gt;</span><br></pre></td></tr></table></figure>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//编程式跳转</span></span><br><span class="line">methods:&#123;</span><br><span class="line">    <span class="function"><span class="title">goPage</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">        uni.navigateTo(&#123;</span><br><span class="line">            <span class="comment">//页面路径</span></span><br><span class="line">            url:<span class="string">&#x27;/page/index/index&#x27;</span></span><br><span class="line">        &#125;)</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">//跳转到tabbar页面</span></span><br><span class="line">methods:&#123;</span><br><span class="line">    <span class="function"><span class="title">goPage</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">        uni.switchTab(&#123;</span><br><span class="line">            <span class="comment">//页面路径</span></span><br><span class="line">            url:<span class="string">&#x27;/page/index/index&#x27;</span></span><br><span class="line">        &#125;)</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h2 id="跳转页面传参"><a href="#跳转页面传参" class="headerlink" title="跳转页面传参"></a>跳转页面传参</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>参数用查询字符串的方式去传递</span><br><span class="line"><span class="number">2.</span>参数取值在onLoad的钩子函数里的参数了去取</span><br></pre></td></tr></table></figure>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//示例</span></span><br><span class="line">uni.navigateTo(&#123;</span><br><span class="line">    url: <span class="string">&#x27;test?id=1&amp;name=uniapp&#x27;</span></span><br><span class="line">&#125;);</span><br><span class="line"><span class="comment">//取参</span></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">default</span> &#123;</span><br><span class="line">    onLoad: <span class="function"><span class="keyword">function</span> (<span class="params">option</span>) </span>&#123; <span class="comment">//option为object类型，会序列化上个页面传递的参数</span></span><br><span class="line">        <span class="built_in">console</span>.log(option.id); <span class="comment">//打印出上个页面传递的参数。</span></span><br><span class="line">        <span class="built_in">console</span>.log(option.name); <span class="comment">//打印出上个页面传递的参数。</span></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h2 id="组件的创建和传值"><a href="#组件的创建和传值" class="headerlink" title="组件的创建和传值"></a>组件的创建和传值</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span>在编辑器里右键就会有新建组件按钮</span><br><span class="line"><span class="number">2.</span>组件的生命周期和vue中的一致</span><br><span class="line"><span class="number">3.</span>组件的传值 和vue一直 这里就不在演示了</span><br></pre></td></tr></table></figure>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//这里我们写跨组件传值</span></span><br><span class="line">核心API 就是uni.$emit(<span class="string">&#x27;自定义事件&#x27;</span>,你要传的值) uni.$on(<span class="string">&#x27;自定义事件名称&#x27;</span>,<span class="function"><span class="keyword">function</span>(<span class="params">res</span>)</span>&#123;<span class="string">&#x27;这里的res就是传过来的值&#x27;</span>&#125;)</span><br></pre></td></tr></table></figure>
</article><div class="post-copyright"><div class="post-copyright__title"><span class="post-copyright-info"><h>Uni-app</h></span></div><div class="post-copyright__type"><span class="post-copyright-info"><a href="http://example.com/2020/04/21/uni-app/">http://example.com/2020/04/21/uni-app/</a></span></div><div class="post-copyright-m"><div class="post-copyright-m-info"><div class="post-copyright-a"><h>作者</h><div class="post-copyright-cc-info"><h>北城韩雨</h></div></div><div class="post-copyright-c"><h>发布于</h><div class="post-copyright-cc-info"><h>2020-04-21</h></div></div><div class="post-copyright-u"><h>更新于</h><div class="post-copyright-cc-info"><h>2019-06-03</h></div></div><div class="post-copyright-c"><h>许可协议</h><div class="post-copyright-cc-info"><a class="icon" rel="noopener" target="_blank" title="Creative Commons" href="https://creativecommons.org/"><i class="fab fa-creative-commons"></i></a><a rel="noopener" target="_blank" title="CC BY-NC-SA 4.0" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">CC BY-NC-SA 4.0</a></div></div></div></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/%E5%B0%8F%E7%A8%8B%E5%BA%8F/">小程序</a></div><div class="post_share"></div></div><link rel="stylesheet" href="/" media="defer" onload="this.media='all'"/><div class="post-reward"><button class="tip-button reward-button"><span class="tip-button__text">打赏</span><div class="coin-wrapper"><div class="coin"><div class="coin__middle"></div><div class="coin__back"></div><div class="coin__front"></div></div></div><div class="reward-main"><ul class="reward-all"><li class="reward-item"><a href="/img/weixin.jpg" target="_blank"><img class="post-qr-code-img" src="/img/weixin.jpg" alt="微信"/></a><div class="post-qr-code-desc">微信</div></li><li class="reward-item"><a href="/img/taobao.jpg" target="_blank"><img class="post-qr-code-img" src="/img/taobao.jpg" alt="支付宝"/></a><div class="post-qr-code-desc">支付宝</div></li></ul></div></button></div><script defer="defer" src="/"></script><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/2020/04/22/ES6/"><img class="prev-cover" src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic.vjshi.com%2F2018-07-17%2Faf41dabad727ba80c9ca8a2bfbd22a58%2F00004.jpg%3Fx-oss-process%3Dstyle%2Fwatermark&amp;refer=http%3A%2F%2Fpic.vjshi.com&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=jpeg?sec=1629530659&amp;t=bbcfe1e86f393eecbb0722db1b92e475" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">ES6/ES7/ES8/ES9/ES10/ES11</div></div></a></div><div class="next-post pull-right"><a href="/2020/04/20/%E5%85%AC%E4%BC%97%E5%8F%B7%E9%85%8D%E7%BD%AE/"><img class="next-cover" src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic.vjshi.com%2F2018-07-17%2Faf41dabad727ba80c9ca8a2bfbd22a58%2F00004.jpg%3Fx-oss-process%3Dstyle%2Fwatermark&amp;refer=http%3A%2F%2Fpic.vjshi.com&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=jpeg?sec=1629530659&amp;t=bbcfe1e86f393eecbb0722db1b92e475" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">微信公众号配置</div></div></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="/img/my.jpg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">北城韩雨</div><div class="author-info__description">一个前端界的小学生</div></div><div class="card-info-data"><div class="card-info-data-item is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">65</div></a></div><div class="card-info-data-item is-center"><a href="/tags/"><div class="headline">标签</div><div class="length-num">23</div></a></div><div class="card-info-data-item is-center"><a href="/categories/"><div class="headline">分类</div><div class="length-num">21</div></a></div></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/wazer1987"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="/wangzhengvslike@163.com" target="_blank" title="Email"><i class="fas fa-envelope"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div><div class="announcement_content"><p>感谢访问本站，如喜欢请收藏。本站主要分享前端知识，立志成为资深前端工程师，但目前是一个前端界的小学生 若喜欢可以打赏请博主喝一杯冰阔落</p> <p>另外请大家多多支持淼哥的开源项目</p> <p>https://github.com/flipped-aurora/gin-vue-admin</p> <p>🌟🌟欢迎大家start 🌟🌟</p> <p>欢迎加入博主的前端技术交流群</p> <p style="background:rgba(255,255,255,1);margin:0"> <img src="/img/code.png"></img> </p></div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#uni-app%E4%BB%8B%E7%BB%8D"><span class="toc-text">uni-app介绍</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA"><span class="toc-text">环境搭建</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%96%87%E4%BB%B6%E7%9B%AE%E5%BD%95%E8%AF%A6%E8%A7%A3"><span class="toc-text">文件目录详解</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#page-json%E6%96%87%E4%BB%B6%E8%AF%A6%E8%A7%A3"><span class="toc-text">page.json文件详解</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%88%9B%E5%BB%BA%E6%96%B0%E7%9A%84%E9%A1%B5%E9%9D%A2"><span class="toc-text">创建新的页面</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Tabbar%E7%9A%84%E9%85%8D%E7%BD%AE"><span class="toc-text">Tabbar的配置</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#condition%E5%90%AF%E5%8A%A8%E6%A8%A1%E5%BC%8F%E9%85%8D%E7%BD%AE"><span class="toc-text">condition启动模式配置</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#uni-app%E7%BB%84%E4%BB%B6%E7%9A%84%E4%BD%BF%E7%94%A8"><span class="toc-text">uni-app组件的使用</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#uni-app%E6%A0%B7%E5%BC%8F"><span class="toc-text">uni-app样式</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#uni-app%E4%B8%AD%E4%BD%BF%E7%94%A8%E9%A2%84%E7%BC%96%E8%AF%91%E5%A4%84%E7%90%86%E5%99%A8sass%E6%88%96%E8%80%85less"><span class="toc-text">uni-app中使用预编译处理器sass或者less</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#uni-app%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F"><span class="toc-text">uni-app生命周期</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E9%A1%B5%E9%9D%A2%E7%9A%84%E4%B8%8B%E6%8B%89%E5%88%B7%E6%96%B0%E7%AC%AC%E4%B8%80%E7%A7%8D%E6%96%B9%E5%BC%8F"><span class="toc-text">页面的下拉刷新第一种方式</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E9%A1%B5%E9%9D%A2%E4%B8%8B%E6%8B%89%E5%88%B7%E6%96%B0%E7%AC%AC%E4%BA%8C%E7%A7%8D%E6%96%B9%E5%BC%8F"><span class="toc-text">页面下拉刷新第二种方式</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%B8%8A%E6%8B%89%E5%8A%A0%E8%BD%BD"><span class="toc-text">上拉加载</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%BD%91%E7%BB%9C%E8%AF%B7%E6%B1%82"><span class="toc-text">网络请求</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%95%B0%E6%8D%AE%E7%BC%93%E5%AD%98"><span class="toc-text">数据缓存</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%9B%BE%E7%89%87%E4%B8%8A%E4%BC%A0%E5%92%8C%E9%A2%84%E8%A7%88"><span class="toc-text">图片上传和预览</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%9D%A1%E4%BB%B6%E7%BC%96%E8%AF%91%E8%B7%A8%E6%AE%B5%E5%85%BC%E5%AE%B9"><span class="toc-text">条件编译跨段兼容</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%AF%BC%E8%88%AA%E8%B7%B3%E8%BD%AC"><span class="toc-text">导航跳转</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E8%B7%B3%E8%BD%AC%E9%A1%B5%E9%9D%A2%E4%BC%A0%E5%8F%82"><span class="toc-text">跳转页面传参</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%BB%84%E4%BB%B6%E7%9A%84%E5%88%9B%E5%BB%BA%E5%92%8C%E4%BC%A0%E5%80%BC"><span class="toc-text">组件的创建和传值</span></a></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/2021/04/16/gin-vue-admin/" title="Gin-Vue-Admin"><img src="/img/gin-vue-admin.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Gin-Vue-Admin"/></a><div class="content"><a class="title" href="/2021/04/16/gin-vue-admin/" title="Gin-Vue-Admin">Gin-Vue-Admin</a><time datetime="2021-04-15T16:00:00.000Z" title="发表于 2021-04-16 00:00:00">2021-04-16</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/01/08/Vue%E6%BA%90%E7%A0%81%E5%BC%80%E5%8F%91%E4%B9%8B%E7%BB%84%E4%BB%B6%E7%9A%84%E6%B8%B2%E6%9F%9310/" title="Vue源码开发-组件的渲染10"><img src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic.vjshi.com%2F2018-07-17%2F3eca5394963b50e37b7be2ba320029ec%2F00003.jpg%3Fx-oss-process%3Dstyle%2Fwatermark&amp;refer=http%3A%2F%2Fpic.vjshi.com&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=jpeg?sec=1629530644&amp;t=10679b5732c52e39eeb588040240a790" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Vue源码开发-组件的渲染10"/></a><div class="content"><a class="title" href="/2021/01/08/Vue%E6%BA%90%E7%A0%81%E5%BC%80%E5%8F%91%E4%B9%8B%E7%BB%84%E4%BB%B6%E7%9A%84%E6%B8%B2%E6%9F%9310/" title="Vue源码开发-组件的渲染10">Vue源码开发-组件的渲染10</a><time datetime="2021-01-07T16:00:00.000Z" title="发表于 2021-01-08 00:00:00">2021-01-08</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/01/07/Vue%E6%BA%90%E7%A0%81%E5%BC%80%E5%8F%91%E4%B9%8B%E7%BB%84%E4%BB%B6%E7%9A%84%E5%90%88%E5%B9%B6%E7%AD%96%E7%95%A509/" title="Vue源码开发-组件合并策略09"><img src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fcz-video-photo.oss-cn-beijing.aliyuncs.com%2F20191017%2F4cfc341591d242327b67e9ceb6953612_00002.jpg&amp;refer=http%3A%2F%2Fcz-video-photo.oss-cn-beijing.aliyuncs.com&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=jpeg?sec=1629530702&amp;t=80943e12d5239f63beafd6d1c540855f" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Vue源码开发-组件合并策略09"/></a><div class="content"><a class="title" href="/2021/01/07/Vue%E6%BA%90%E7%A0%81%E5%BC%80%E5%8F%91%E4%B9%8B%E7%BB%84%E4%BB%B6%E7%9A%84%E5%90%88%E5%B9%B6%E7%AD%96%E7%95%A509/" title="Vue源码开发-组件合并策略09">Vue源码开发-组件合并策略09</a><time datetime="2021-01-06T16:00:00.000Z" title="发表于 2021-01-07 00:00:00">2021-01-07</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/01/06/Vue%E6%BA%90%E7%A0%81%E5%BC%80%E5%8F%91%E4%B9%8B%E6%95%B0%E7%BB%84%E7%9A%84%E4%BE%9D%E8%B5%96%E6%94%B6%E9%9B%8608/" title="Vue源码开发-数组的依赖收集08"><img src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic.vjshi.com%2F2018-07-17%2F3eca5394963b50e37b7be2ba320029ec%2F00003.jpg%3Fx-oss-process%3Dstyle%2Fwatermark&amp;refer=http%3A%2F%2Fpic.vjshi.com&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=jpeg?sec=1629530644&amp;t=10679b5732c52e39eeb588040240a790" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Vue源码开发-数组的依赖收集08"/></a><div class="content"><a class="title" href="/2021/01/06/Vue%E6%BA%90%E7%A0%81%E5%BC%80%E5%8F%91%E4%B9%8B%E6%95%B0%E7%BB%84%E7%9A%84%E4%BE%9D%E8%B5%96%E6%94%B6%E9%9B%8608/" title="Vue源码开发-数组的依赖收集08">Vue源码开发-数组的依赖收集08</a><time datetime="2021-01-05T16:00:00.000Z" title="发表于 2021-01-06 00:00:00">2021-01-06</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/01/06/Vue%E6%BA%90%E7%A0%81%E5%BC%80%E5%8F%91%E4%B9%8B%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F%E5%90%88%E5%B9%B607/" title="Vue源码开发-生命周期合并07"><img src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic.vjshi.com%2F2018-07-17%2Faf41dabad727ba80c9ca8a2bfbd22a58%2F00004.jpg%3Fx-oss-process%3Dstyle%2Fwatermark&amp;refer=http%3A%2F%2Fpic.vjshi.com&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=jpeg?sec=1629530659&amp;t=bbcfe1e86f393eecbb0722db1b92e475" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Vue源码开发-生命周期合并07"/></a><div class="content"><a class="title" href="/2021/01/06/Vue%E6%BA%90%E7%A0%81%E5%BC%80%E5%8F%91%E4%B9%8B%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F%E5%90%88%E5%B9%B607/" title="Vue源码开发-生命周期合并07">Vue源码开发-生命周期合并07</a><time datetime="2021-01-05T16:00:00.000Z" title="发表于 2021-01-06 00:00:00">2021-01-06</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright"><span>&copy;2017 - 2021</span><svg style="width:2em; height:2em;position: relative;top: 10px;" aria-hidden="true"><use xlink:href="#icon-Butterfly"></use></svg><span>北城韩雨</span></div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div><div class="footer_custom_text"><p><a style="margin-inline:5px" target="_blank" href="https://hexo.io/"><img src="https://img.shields.io/badge/Frame-Hexo-blue?style=flat&logo=hexo" title="博客框架为Hexo"></a><a style="margin-inline:5px" target="_blank" href="https://butterfly.js.org/"><img src="https://img.shields.io/badge/Theme-Butterfly-6513df?style=flat&logo=bitdefender" title="主题采用butterfly"></a><a style="margin-inline:5px" target="_blank" href="https://www.jsdelivr.com/"><img src="https://img.shields.io/badge/CDN-jsDelivr-orange?style=flat&logo=jsDelivr" title="本站使用JsDelivr为静态资源提供CDN加速"></a></p></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/medium-zoom/dist/medium-zoom.min.js"></script><div class="js-pjax"></div><script defer src="/live2d-widget/autoload.js"></script><script src="/js/coin.js"></script><script async src="//at.alicdn.com/t/font_2700632_3rtvhzzpl3h.js"></script><script src="/js/liuxing.js" data-pjax></script><canvas class="fireworks" mobile="false"></canvas><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/fireworks.min.js"></script><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/activate-power-mode.min.js"></script><script>POWERMODE.colorful = true;
POWERMODE.shake = true;
POWERMODE.mobile = false;
document.body.addEventListener('input', POWERMODE);
</script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><!-- hexo injector body_end start --><div class="js-pjax"><script async="async">var arr = document.getElementsByClassName('recent-post-item');
for(var i = 0;i<arr.length;i++){
    arr[i].classList.add('wow');
    arr[i].classList.add('animate__zoomIn');
    arr[i].setAttribute('data-wow-duration', '1s');
    arr[i].setAttribute('data-wow-delay', '0ms');
    arr[i].setAttribute('data-wow-offset', '100');
    arr[i].setAttribute('data-wow-iteration', '1');
  }</script><script async="async">var arr = document.getElementsByClassName('card-widget');
for(var i = 0;i<arr.length;i++){
    arr[i].classList.add('wow');
    arr[i].classList.add('animate__zoomIn');
    arr[i].setAttribute('data-wow-duration', '');
    arr[i].setAttribute('data-wow-delay', '');
    arr[i].setAttribute('data-wow-offset', '');
    arr[i].setAttribute('data-wow-iteration', '');
  }</script></div><script defer src="https://cdn.jsdelivr.net/gh/graingert/wow@1.3.0/dist/wow.min.js"></script><script defer src="https://cdn.jsdelivr.net/npm/hexo-butterfly-wowjs/lib/wow_init.min.js"></script><script async src="//at.alicdn.com/t/font_2032782_8d5kxvn09md.js"></script><!-- hexo injector body_end end --></body></html>